package top.riske.animalhazardassessment.account.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.riske.animalhazardassessment.account.service.AccountService;
import top.riske.animalhazardassessment.common.DTO.AccountDto;

@Tag(name = "RestController",description = "登录，注册接口")
@RestController
public class LoginController {

    @Resource
    private AccountService accountService;

    @Operation(summary = "登录")
    @GetMapping("/login")
    public AccountDto login(@RequestParam String username, @RequestParam String password, HttpServletResponse response) {
        return accountService.login(username, password,response).toDto();
    }

    @Operation(summary = "注册，权限：用户")
    @GetMapping("/register")
    public AccountDto register(@RequestParam String username, @RequestParam String password, HttpServletResponse response) {
        return accountService.register(username, password,response).toDto();
    }


}
